package acwing;

import java.io.*;
import java.util.*;

public class ac788 {
    static final int N = 100010;
    static int[] a = new int[N];
    static int[] t = new int[N];
    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] s = in.readLine().split(" ");
        for(int i = 0; i < n; i ++ ) a[i] = Integer.parseInt(s[i]);
        System.out.println(merge_sort(0, n - 1));
    }

    public static long merge_sort(int l, int r){
        if(l >= r) return 0;
        int mid = l + r >> 1;
        long res = merge_sort(l, mid) + merge_sort(mid + 1, r);
        int i = l, j = mid + 1, k = 0;
        while(i <= mid && j <= r){
            if(a[i] <= a[j]) t[k ++ ] = a[i ++ ];
            else {
                t[k ++ ] = a[j ++ ];
                res += mid - i + 1;
            }
        }
        while (i <= mid) t[k ++ ] = a[i ++ ];
        while (j <= r) t[k ++ ] = a[j ++ ];
        for(i = l, j = 0; i <= r; i ++, j ++ ) a[i] = t[j];
        return res;
    }

}
